﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CopyFile
{
    public partial class frmMain : Form
    {

        
        public frmMain()
        {
            InitializeComponent();
        }


        private void btnQuit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            CopyFileArgs args = new CopyFileArgs()
                                    {Source = txtSourceFilename.Text, Destination = txtDestinationFilename.Text};
            
            new Progress().CopyFile(args);            
        
        }

        private void btnDestination_Click(object sender, EventArgs e)
        {
            sfdDestination.Filter = "Text Files|*.txt";
            sfdDestination.FileName = txtDestinationFilename.Text;
            DialogResult result= sfdDestination.ShowDialog((IWin32Window) this.WindowTarget);
            if(result==System.Windows.Forms.DialogResult.OK)
            {
                txtDestinationFilename.Text =sfdDestination.FileName;
            }
        }

        private void btnSource_Click(object sender, EventArgs e)
        {
            ofdSource.Filter = "Text Files|*.txt";
            ofdSource.FileName = this.txtSourceFilename.Text;
            DialogResult result = ofdSource.ShowDialog((IWin32Window) this.WindowTarget);
            if(result==System.Windows.Forms.DialogResult.OK)
            {
                txtSourceFilename.Text = ofdSource.FileName;                
            }
        }
    }

    public class CopyFileArgs
    {
        public string Destination;
        public string Source;
    }
}
